package com.zahb.qadx.ui.view.captcha

import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.core.view.ViewCompat
import com.luozm.captcha.Captcha

/**
 * Created by Zdw on 2021/06/08 14:17
 */

class CustomCaptcha @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : Captcha(context, attrs, defStyleAttr) {
    private fun init() {
        setCaptchaStrategy(CustomCaptchaStrategy(context))
        maxFailedCount = Int.MAX_VALUE
        val childView = getChildAt(0)
        if (childView is LinearLayout) {
            ViewCompat.setPaddingRelative(
                    childView, 0, childView.paddingTop, 0, childView.paddingBottom)
        }
    }

    init {
        init()
    }
}